package com.yss.sofa.report.engine.cell.visible.result;

import java.util.HashMap;
import java.util.Map;

import com.yss.sofa.report.engine.Const;
import com.yss.sofa.report.engine.cell.ReportCell;
import com.yss.sofa.report.engine.cell.visible.extendable.ExtendableCell;
import com.yss.sofa.report.engine.series.Series;

public class ChartResultCell extends ResultCell{
	private static final long serialVersionUID = 7576938871808365927L;
	private Series series;
	private Map<String,String> record=new HashMap<String, String>();
	private Map<String,String> attr=new HashMap<String, String>();
	protected void init() {
		super.init();
	}
	public void assignTo(ReportCell cell){
		ChartResultCell _=(ChartResultCell)cell;
		super.assignTo(_);
		_.series=this.series.create();
		_.record.clear();
		_.record.putAll(this.record);
		_.attr.clear();
		_.attr.putAll(this.attr);
	}
	public ChartResultCell create(){
		ChartResultCell _=new ChartResultCell();
		this.assignTo(_);
		return _;
	}
	private ChartResultCell(){
		super();
		this.series=null;
		this.record.clear();
	}
	private ChartResultCell(Series series,Map<String,String> record){
		this();
		this.series=series;
		this.record.clear();
		if(record!=null){
			this.record=record;
		}
	}
	public ChartResultCell(int rbegin,int rend,int cbegin,int cend,ExtendableCell from,Series series,Map<String,String> record){
		this(series,record);
		this.rfrom=from.getRfrom();
		this.cfrom=from.getCfrom();
		this.top=from.getTop();
		this.left=from.getLeft();
		this.dataType=from.getDataType();
		//this.autoMerge=true;
		this.move=from.getMove();
		this.rbegin=rbegin;
		this.rend=rend;
		this.cbegin=cbegin;
		this.cend=cend;
		this.fromRbegin=from.getRbegin();
		this.fromRend=from.getRend();
		this.fromCbegin=from.getCbegin();
		this.fromCend=from.getCend();
		this.style=from.getStyle();
		if(from.isAutoMerge()){
			switch (from.getExtend()) {
			case Const.CELL_EXTEND_BOTTOM:
			case Const.CELL_EXTEND_RIGHT_BOTTOM:
				this.mergeTimes=this.getRowInc()/from.getRowInc();
				this.forceMergeTo=ForceMergeTo.FORCE_MERGE_TO_H;
				break;
			case Const.CELL_EXTEND_RIGHT:
			case Const.CELL_EXTEND_BOTTOM_RIGHT:
				this.mergeTimes=this.getColInc()/from.getColInc();
				this.forceMergeTo=ForceMergeTo.FORCE_MERGE_TO_V;
				break;
			default:
				this.mergeTimes=1;
				this.forceMergeTo=ForceMergeTo.FORCE_MERGE_TO_N;
				break;
			}
		} else {
			this.mergeTimes=1;
			switch (from.getExtend()) {
			case Const.CELL_EXTEND_BOTTOM:
			case Const.CELL_EXTEND_RIGHT_BOTTOM:
				this.forceMergeTo=ForceMergeTo.FORCE_MERGE_TO_H;
				break;
			case Const.CELL_EXTEND_RIGHT:
			case Const.CELL_EXTEND_BOTTOM_RIGHT:
				this.forceMergeTo=ForceMergeTo.FORCE_MERGE_TO_V;
				break;
			default:
				this.forceMergeTo=ForceMergeTo.FORCE_MERGE_TO_N;
				break;
			}
		}
		this.forceMerge=from.getForceMerge();
		this.html="";
		this.attr.clear();
		this.attr.putAll(from.getAttr());
	}

	public String getValue() {
		return null;
	}
	
	public Map<String,String> getRecord(){
		return this.record;
	}
	
	public Map<String,String> getAttr(){
		return this.attr;
	}

	public Series getSeries() {
		return series;
	}
}
